/*
 * Reader.cpp
 *
 *  Created on: 05.11.2013
 *      Author: ulgish
 */

#include <lab4/Reader.h>
#include <sstream>
#include <cstdio>
#include <SyncWriter.h>
#include <unistd.h>
using std::string;
using std::stringstream;
namespace DT {

int Reader::delayInSecond = 5;

void* Reader::run(void* arg){
	InformationFond* iFond = (InformationFond*) arg;
	stringstream ss;

	while(iFond->isOpen()){
		string msg = iFond->read();
		ss << "Reader [id:" << getId() << "] read message = " << msg;
		writer << ss.str();
		sleep(Reader::delayInSecond);
		ss.str("");
	}

	return NULL;
}
Reader::Reader(){
	// TODO Auto-generated constructor stub
}

Reader::~Reader() {
	// TODO Auto-generated destructor stub
}

}
